<template>
  <div class="navigation-container">
    <div class="header">
      <!-- <div class="mask"></div> -->
      <div class="top-nav flex flex-row justify-space-between align-center">
        <div class="left-title">{{ globalConfig.fullName }}医务一网通办</div>
        <div class="right-account flex flex-row">
          <div class="mr10 line-height-20 font16">{{ name }}</div>
          |<div
            class="ml10 font16 line-height-20 cursor-p password"
            @click="goProfile"
          >
            <i class="el-icon-edit" />修改密码
          </div>
          <span class="ml10">|</span>
          <div
            v-if="roles.includes('admin')"
            class="ml10 font16 line-height-20 cursor-p control"
            @click="goAdmin"
          >
            <i class="el-icon-switch-button" />控制台
          </div>
          <span v-if="roles.includes('admin')" class="ml10">|</span>
          <div class="ml10 font16 line-height-20 cursor-p" @click="logout">
            <i class="el-icon-switch-button" />退出
          </div>
        </div>
      </div>
      <div class="content">
        <div class="title">{{ globalConfig.fullName }}医务管理网上办事大厅欢迎你！</div>
        <div class="title">{{ globalConfig.fullName }}医务一网通办</div>
        <div class="flex flex-row mt30">
          <div class="card flex flex-row" @click="goApp('医疗技术管理平台', 'xjsxxm', '/project/applyList')">
            <img src="@/assets/left.85026898.png" alt="">
            <div class="flex flex-column flex-auto text-center">
              <div class="number">{{ dashboardValue.count.my_create }}</div>
              <div class="label">我的发起</div>
            </div>
          </div>
          <div class="card flex flex-row" @click="goApp('医疗技术管理平台', 'xjsxxm', '/project/upcoming')">
            <img src="@/assets/right.ff5fa629.png" alt="">
            <div class="flex flex-column flex-auto text-center">
              <div class="number">{{ todoCount }}</div>
              <div class="label">我的审批</div>
            </div>
          </div>
          <div class="card flex flex-row" @click="goApp('医疗技术管理平台', 'xjsxxm', '/annual/todo')">
            <img src="@/assets/right.ff5fa629.png" alt="">
            <div class="flex flex-column flex-auto text-center">
              <div class="number">{{ nsCount }}</div>
              <div class="label">阶段评审填报</div>
            </div>
          </div>
          <div class="card flex flex-row" @click="goApp('医疗技术管理平台', 'xjsxxm', '/annual/affirm')">
            <img src="@/assets/right.ff5fa629.png" alt="">
            <div class="flex flex-column flex-auto text-center">
              <div class="number">{{ affirmCount }}</div>
              <div class="label">阶段评审确认</div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 常见服务 -->
    <div class="middle">
      <div class="title">常用服务</div>
      <div class="card-list flex flex-row align-center">
        <div class="flex flex-row align-center width330">
          <div class="card-box flex flex-row align-center" @click="goApp('医疗技术管理平台','xjsxxm','/project/apply')">
            <img src="@/assets/008.png" alt="">
            <div class="label flex-auto pl30">医疗技术管理平台</div>
          </div>

        </div>
        <div class="flex flex-row align-center width330">
          <div class="card-box flex flex-row align-center" @click="goApp('不安全事件系统', 'baqsj', '/baqsj/report')">
            <img src="@/assets/008.png" alt="">
            <div class="label flex-auto pl30">不安全事件系统</div>
          </div>

        </div>

      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { initData } from '@/api/dashboard'
import { workOrderList } from '@/api/xjs/ns-order'
import { workOrderTodoList } from '@/api/xjs/work-order'
export default {
  name: 'Navigation',
  components: {},
  data() {
    return {
      dashboardValue: {
        count: {}
      },
      ticketList: [],
      todoList: [],
      nsCount: 0,
      affirmCount: 0,
      todoCount: 0,
      queryList: {},
      listQuery: {
        page: 1,
        per_page: 1000
      },
      listTodoQuery: {
        page: 1,
        per_page: 1000
      }
    }
  },
  computed: {
    ...mapGetters(['avatar', 'device', 'name', 'roles', 'globalConfig'])
  },
  created() {
    this.getInitData()
    this.getMyTodoList()
    this.getMyNsList()
    this.getMyAffirmList()
  },
  methods: {
    getMyTodoList() {
      this.listTodoQuery.classify = 1
      workOrderTodoList(this.listTodoQuery).then(response => {
        this.todoList = response.data.data
        this.todoCount = response.data.total_count
      })
    },
    getMyNsList() {
      this.listQuery.classify = 1
      this.listQuery.process = 2
      this.listQuery.nodeName = '阶段评审填报'
      workOrderList(this.listQuery).then(response => {
        this.ticketList = response.data.data
        this.nsCount = response.data.total_count
      })
    },
    getMyAffirmList() {
      this.listQuery.classify = 1
      this.listQuery.process = 2
      this.listQuery.nodeName = '阶段评审确认'
      workOrderList(this.listQuery).then(response => {
        this.affirmCount = response.data.total_count
      })
    },
    getInitData() {
      initData(this.queryList).then(response => {
        this.dashboardValue = response.data
      })
    },
    goAdmin() {
      localStorage.setItem('currentApp', JSON.stringify({ name: '领导驾驶舱', mid: 'admin' }))
      this.$router.push({ path: '/project/apply' })
    },
    goApp(name, mid, url) {
      localStorage.setItem('currentApp', JSON.stringify({ name: name, mid: mid }))
      this.$router.push({ path: url })
    },
    goProfile() {
      this.$router.push({ path: '/profile/index' })
    },
    async logout() {
      this.$confirm('确定注销并退出系统吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$store.dispatch('user/LogOut').then(() => {
          location.reload()
        })
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.navigation-container {
    .header {
        background: url("~@/assets/navigation-top.jpg") no-repeat 100%;
        width: 100%;
        height: 430px;
        background-size: cover;
        position: relative;
        .mask {
            position: absolute;
            width: 100%;
            height: 430px;
            background: rgba(0, 0, 0, 0.6);
        }
        .top-nav {
            color: #fff;
            font-size: 17px;
            padding: 10px;
            height: 50px;
            .left-title {
                font-size: 16px;
                padding-left: 30px;
                padding-top: 10px;
            }
            .right-account {
                padding-right: 30px;
            }
            .control {
                color: #0898eb;
            }
            .password {
                color: #fecc11;
            }
        }

        .content {
            color: #fff;
            padding-left: 120px;
            margin-top: 100px;
            .title {
                font-size: 28px;
                margin-bottom: 15px;
            }
            .card {
                width: 250px;
                height: 100px;
                background: #fff;
                margin-right: 30px;
                border-radius: 10px;
                padding: 10px;
                align-items: center;
                color: #000;
                position: relative;
                top: 0;
                right: 0;
                transition: 0.2s all ease;
                img {
                    width: 80px;
                    height: 63px;
                }
                &:hover {
                    top: -3px;
                    right: -1px;
                    -webkit-box-shadow: 0 15px 30px 0 rgb(255 255 255 / 30%);
                    box-shadow: 0 15px 30px 0 rgb(255 255 255 / 30%);
                    cursor: pointer;
                }
                .number {
                    color: red;
                    font-size: 28px;
                    font-weight: 600;
                }
                .label {
                    font-size: 17px;
                    font-weight: 600;
                }
            }
        }
    }

    .middle {
        padding: 10px 50px;
        margin-top: 10px;
        .title {
            font-size: 22px;
            font-weight: 600;
            color: rgba($color: #000000, $alpha: 0.65);
        }
        img {
            width: 50px;
            height: 50px;
        }
        .card-box {
            background: #e88663;
            border-radius: 10px;
            margin: 20px 50px 20px 0px;
            padding: 25px 20px;
            position: relative;
            top: 0;
            right: 0;
            flex: 1;
            transition: 0.2s all ease;
            .label {
                font-size: 19px;
                font-weight: bold;
                color: #fff;
            }
            &:hover {
                top: -3px;
                right: -1px;
                -webkit-box-shadow: 0 15px 30px 0 rgb(0 0 0 / 30%);
                box-shadow: 0 15px 30px 0 rgb(0 0 0 / 30%);
                cursor: pointer;
            }
        }
    }
}
</style>
